package application;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class DataConnectionToTransport {
	
	private Socket socket;
	private OutputStream outputStream;
	private InputStream inputStream;
	private Application application;
	/**
	 * Constructs a DataConnectionToTransport that maintains the connection from the application to the transport layer.
	 * @param sock
	 * @throws IOException exception if the input of output stream can't be found
	 */
	public DataConnectionToTransport(Socket sock, Application application) throws IOException{
		this.socket = sock;
		this.application = application;
		this.inputStream = socket.getInputStream();
		this.outputStream = socket.getOutputStream();
	}
	/**
	 * returns the outputStream of the connection
	 * @return
	 */
	public OutputStream getOutputStream(){
		return this.outputStream;
	}
	/**
	 * returns the inputStream of the connection
	 * @return
	 */
	public InputStream getInputStream(){
		return this.inputStream;
	}
	/**
	 * Disconnects the application
	 */
	public void disconnect(){
		try {
			socket.close();
		} catch (IOException e) {
			//Doe niets, socket is blijkbaar al dicht
		}
	}
}
